﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using SilverChart.Core.Log;
using SilverChart.Core.Configuration;
using SilverChart.Configuration;
using System.Collections.Generic;

namespace SilverChart.BarChart {
    public class BarChartConfigurationWrapper {
        private static Logger logger = Logger.GetLogger<BarChartConfigurationWrapper>();
        private Element Data;

        public const String ITEM_NAME_FILL = "fill";
        public readonly static Color DefaultFillColor = Color.FromArgb(0xAA, 0xF0, 0xE6, 0x8C);//#AAF0E68C
        private BrushValueItemHelper fill;

        public const String ITEM_NAME_STROKE = "stroke_color";
        public readonly static Color DefaultStroke = Color.FromArgb(0x99, 0x4B, 0x00, 0x82);//#994B0082
        private BrushValueItemHelper stroke;

        public const String ITEM_NAME_STROKETHICKNESS = "stroke_thickness";
        public const Double DefaultStrokeThickness = 2.0d;
        private SimpleValueItemHelper<Double> strokeThichness;

        public BarChartConfigurationWrapper(Element data) {
            Data = data;

            fill = new BrushValueItemHelper(Data, ITEM_NAME_FILL, DefaultFillColor);
            stroke = new BrushValueItemHelper(Data, ITEM_NAME_STROKE, DefaultStroke);
            strokeThichness = new SimpleValueItemHelper<Double>(Data, ITEM_NAME_STROKETHICKNESS, DefaultStrokeThickness);
        }

        public Boolean ShowTip { get { return Data.ShowTip; } }
        public IList<Double> Values { get { return Data.Values; } }
        public String LegendName { get { return Data.LegendName; } }

        public Brush Fill { get { return fill.Value; } }
        public Brush Stroke { get { return stroke.Value; } }
        public Double StrokeThickness { get { return strokeThichness.Value; } }

        public Border Bar {
            get {
                Border bar = new Border();
                bar.Background = Fill;
                bar.BorderThickness = new Thickness(StrokeThickness, StrokeThickness, StrokeThickness, 0);
                bar.Margin = new Thickness(1, 0, 1, 0);
                bar.CornerRadius = new CornerRadius(3, 3, 0, 0);
                bar.HorizontalAlignment = HorizontalAlignment.Stretch;
                bar.VerticalAlignment = VerticalAlignment.Stretch;
                bar.BorderBrush = Stroke;
                return bar;
            }
        }
    }
}
